//
//  ESBaseWebViewController.m
//  EasyStyle
//
//  Created by FK on 16/1/8.
//  Copyright © 2016年 FK. All rights reserved.
//

#import "ESBaseWebViewController.h"
@import WebKit;
@interface ESBaseWebViewController ()<WKNavigationDelegate,WKUIDelegate>
@property (nonatomic, retain) WKWebView *webView;
@property (nonatomic, retain) NSString *currentUrlString;
@end

@implementation ESBaseWebViewController


- (instancetype)init{
    self = [super init];
    if (self) {
        [self createWebViewWithFrame:self.frame];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createWebViewWithFrame:frame];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self createWebViewWithFrame:self.frame];
    }
    return self;
}

- (void)createWebViewWithFrame:(CGRect)frame{
    //默认打开WKWebView
//    static dispatch_once_t onceToken;
//    static BOOL supportWKWebView;
//    dispatch_once(&onceToken, ^{
//        supportWKWebView = NSClassFromString(@"WKWebView") && NSClassFromString(@"SGWebViewNew");
//        if ([[NSUserDefaults standardUserDefaults] objectForKey:@"EnableWKWebView"] == nil) {
//            [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"EnableWKWebView"];
//        }
//    });
    //supportWKWebView = NO;
    self.webView = [[WKWebView alloc]init];
    [self.webView setFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
    self.webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    [self addSubview:self.webView];
    self.backgroundColor = [UIColor clearColor];

}
@end
